﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>SearchPart</title>
    <link rel="stylesheet" href="~/Content/bootstrap.min.css" />
    <link rel="stylesheet" href="~/Content/bootstrap-table.css" />
    <link rel="stylesheet" href="~/Content/style.css" />
    <style>
        #box_sel{
            width:100%;
            height:100%;
            left:0;
            top:0;
            display:block;
            margin-left:0;
            margin-top:0;
        }
        td
        {
            line-height:normal !important;
        }
    </style>
</head>
<body>
   <div id="box_sel" style="">
        <p><input class="inp"  type="text" /><input class="sub jb" type="submit" value="查找" onclick="InitTable();"/><a class="jb" onclick="onsubmititem();">确定</a><a class="jb" onclick="onCloseSelect();">取消</a></p>
        <div class="table2">
            <table></table>
        </div>
    </div>

    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script src="~/Scripts/bootstrap-table.js"></script>
    <script src="~/Scripts/locale/bootstrap-table-zh-CN.js"></script>
    <script src="~/Scripts/uilts.js"></script>
    <script>
        var $table = $('table');
        function InitTable(pageIndex, pageSize) {
            if (typeof pageIndex == "object") {
                pageIndex = undefined;
            }
            $table.bootstrapTable('destroy');
            $table.bootstrapTable({
                method: "post",  //使用get请求到服务器获取数据
                url: "/Product/Partlistdata", //获取数据的Servlet地址
                striped: true,  //表格显示条纹
                pagination: true, //启动分页
                pageSize: pageSize == null ? 10 : pageSize,  //每页显示的记录数
                pageNumber: pageIndex == null ? 1 : pageIndex, //当前第几页
                pageList: [10, 20, 50, 100, 250],  //记录数可选列表
                search: false,  //是否启用查询
                sidePagination: "server", //表示服务端请求
                sortName: "ID",
                //设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
                //设置为limit可以获取limit, offset, search, sort, order
                queryParamsType: "undefined",
                queryParams: function queryParams(params) {   //设置查询参数
                    var param = {
                        PageIndex: params.pageNumber,
                        PageSize: params.pageSize,
                        sorter: params.sortName + " " + params.sortOrder,
                        search: $("input.inp[type='text']").val().trim()
                    };
                    return param;
                },
                columns: [
                    {
                        field: 'Sno',
                        title: "零件编号",
                        align: 'center',
                        valign: 'middle'
                    },
                    {
                        field: 'Name',
                        title: '零件名称',
                        align: 'center',
                        valign: 'middle'
                    }
                ],
                onLoadSuccess: function () {
                    $('table tr').click(function () {
                        uncheckAll($table);
                        $('table tr').removeClass("act");
                        $(this).addClass("act");
                        $table.bootstrapTable('check', $(this).attr("data-index"));
                    });
                }
            });
        }

        InitTable();

    </script>
    <script>
        function onsubmititem() {
            var selected = $table.bootstrapTable('getAllSelections');
            if (selected.length == 0) {
                alert("没有选择行！");
                return;
            }
            if (top != null && top != self) {
                if (top.partSelectCallback != undefined) {
                    top.partSelectCallback({ id: selected[0].ID, sno: selected[0].Sno, name: selected[0].Name });
                }
            }
        }

        function onCloseSelect() {
            if (top != null && top != self) {
                if (top.CloseSelectPartDiv != undefined) {
                    top.CloseSelectPartDiv();
                }
            }
        }
    </script>
</body>
</html>
